﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bootloader.zlgcan
{
    // CAN ID过滤器
    public class CanFilter
    {
        private readonly HashSet<uint> _ids;

        // 构造只读的id过滤列表
        public CanFilter(IEnumerable<uint> ids)
        {
            // 如果 ids 为 null，就用空集合；否则用传入的 ID 构建 HashSet
            _ids = ids == null
                ? new HashSet<uint>()
                : new HashSet<uint>(ids);
        }

        // id在列表中存在返回true
        public bool IsInterested(uint canId)
        {
            return _ids.Contains(canId);
        }
    }
}
